package org.geektimes.reactive.streams.simple;

import org.geektimes.reactive.streams.throwable.ThrowableConsumer;

import java.util.function.Consumer;

/**
 * @FileName: ReactiveUtils
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/3/30 - 下午11:28
 */
public class ReactiveUtils {

    public static <T> Consumer<DefaultSubscriberWrapper<T>> accept(ThrowableConsumer<DefaultSubscriberWrapper<T>> consumer) {
        return s -> {
            try {
                consumer.accept(s);
            } catch (Throwable throwable) {
                s.onError(throwable);
            }
        };
    }
}
